﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using Easy.BLL;
using Easy.Operation.Data;

namespace Easy.Web.Pages.EntityPages
{
    public partial class AppFormPreview : BasePage
    {
        public string coreScript { get; set; }
        public string UserScript { get; set; }
        public string UserHtml { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

            }
            catch (Exception)
            {
                
                throw;
            }
            string EntityName = Context.Request["entityname"];
            if (string.IsNullOrWhiteSpace(EntityName))
            {
                throw new Exception("发生错误");
            }
            PageForm form=new PageForm(Context,this.GetSystemUser());
            coreScript = string.Format(@"
                                        var EntityName='{0}';
                                        var EntityDisplayName='{1}';
                                        var Prefix='{2}';
                                        var FormId='{3}';
                                        var XFormData={4};
                                        var EntityField={5};
                                        var EntityOption={6};
                                        var Privilege={7};
                                        var FunctionPrivilege={8};",
                                        form.EntityName,
                                        form.EntityDispalayName,
                                        form.PreFix,
                                        form.ID,
                                        JsonConvert.SerializeObject(form.EntityData),
                                        JsonConvert.SerializeObject(form.Fields),
                                        JsonConvert.SerializeObject(form.Options),
                                        JsonConvert.SerializeObject(form.UserPrivilege),
                                        JsonConvert.SerializeObject(form.FunctionPrivilege));
            string userHtml = Context.Request["userhtml"];
            UserHtml = HttpUtility.HtmlDecode(userHtml);
            UserScript = "";
            
        }
    }
}